创建和删除线程(动态线程)
创建线程
1 | rt_thread_t rt_thread_create(const char* name, //线程名称 |
删除线程
1 | rt_err_t rt_thread_delete( |
示例
1 |
|
初始化和脱离线程(静态线程)
初始化线程
1 | rt_err_t rt_thread_init(struct rt_thread* thread, //线程句柄 |
脱离线程
1 | rt_err_t rt_thread_detach( |
示例
1 |
|
启动线程
1 | rt_err_t rt_thread_startup(rt_thread_t thread); |
获得当前线程
1 | rt_thread_t rt_thread_self(void); |
使线程让出处理器资源
1 | rt_err_t rt_thread_yield(void); |
使线程睡眠
1 | rt_err_t rt_thread_sleep(rt_tick_t tick); |
挂起和恢复线程
挂起线程
1 | rt_err_t rt_thread_suspend(rt_thread_t thread); |
恢复线程
1 | rt_err_t rt_thread_resume(rt_thread_t thread); |
控制线程
1 | rt_err_t rt_thread_control(rt_thread_t thread, //线程句柄 |
设置和删除空闲钩子
1 | rt_err_t rt_thread_idle_sethook(void (*hook)(void)); |
设置调度器钩子
1 | void rt_scheduler_sethook(void (*hook)(struct rt_thread* from, struct rt_thread* to)); |